package com.ysccc.shares.web.vo;

import java.io.Serializable;
import java.text.DecimalFormat;

import org.springframework.beans.BeanUtils;

import com.ysccc.shares.entity.SharesDaily;
import com.ysccc.tools.Dates;

import lombok.Data;

@Data
public class SharesDailyVo implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private Long id;

	/** 日期 */
	private String day;
	
	/** 昨日收盘价 */
	private String lastDayEndPrice;
	
	/** 今日开盘价 */
	private String startPrice;
	
	/** 今日收盘价 */
	private String endPrice;
	
	/** 今日最高价 */
	private String maxPrice;
	
	/** 今日最低价 */
	private String minPrice;
	
	/** 成交的股票数 */
	private Long tradeNum;
	
	/** 成交金额 */
	private Long tradeAmount;
	
	/** 涨跌金额 */
	private String upDownAmount;
	
	/** 涨跌比例 */
	private String upDownRate;

	public SharesDailyVo(SharesDaily sharesDaily) {
		super();
		BeanUtils.copyProperties(sharesDaily, this);
		this.day = Dates.format(sharesDaily.getDay());
		DecimalFormat format = new DecimalFormat("#.##");
		if (sharesDaily.getLastDayEndPrice() != null) {
			this.lastDayEndPrice = format.format(sharesDaily.getLastDayEndPrice());
		}
		if (sharesDaily.getStartPrice() != null) {
			this.startPrice = format.format(sharesDaily.getStartPrice());
		}
		if (sharesDaily.getEndPrice() != null) {
			this.endPrice = format.format(sharesDaily.getEndPrice());
		}
		if (sharesDaily.getMaxPrice() != null) {
			this.maxPrice = format.format(sharesDaily.getMaxPrice());
		}
		if (sharesDaily.getMinPrice() != null) {
			this.minPrice = format.format(sharesDaily.getMinPrice());
		}
		if (sharesDaily.getUpDownAmount() != null) {
			this.upDownAmount = format.format(sharesDaily.getUpDownAmount());
		}
		if (sharesDaily.getUpDownRate() != null) {
			this.upDownRate = format.format(sharesDaily.getUpDownRate());
		}
	}
}
